<template>
    <div class="recordList">
        <navBar titleName="病历列表" style="width: 100%"></navBar>
        <div class="list">
            <div class="lsit_style" v-for="(item,index) in list" :key="index" @click="chooseMyRecord(item)">
                <nut-row
                        style="min-height: 35px !important;line-height: 35px !important;margin-top: 20px;padding-bottom: 5px;">
                    <nut-col :span="8">
                        <div class="flex-content" style="text-align: left;color: #78A4F5;font-size: 1.2em;">
                            {{item.pname}}
                        </div>
                    </nut-col>
                    <nut-col :span="16">
                        <div class="flex-content flex-content-light"
                             style="text-align: left;color: #666666;padding-right: 20px;font-size: 0.8em;">
                            病历号 {{item.recordId + "" + item.lastUpdateDate}}
                        </div>
                    </nut-col>
                    <nut-col :span="8" style="line-height: 25px !important;padding-top: 10px;">
                        <div class="flex-content" style="text-align: left;font-size: 0.8em;">医生姓名</div>
                    </nut-col>
                    <nut-col :span="16" style="line-height: 25px !important;padding-top: 10px;">
                        <div class="flex-content" style="text-align: left;font-size: 0.8em;">{{item.dname}}</div>
                    </nut-col>
                    <nut-col :span="8" style="line-height: 25px !important;">
                        <div class="flex-content" style="text-align: left;font-size: 0.8em;">接诊时间</div>
                    </nut-col>
                    <nut-col :span="16" style="line-height: 25px !important;">
                        <div class="flex-content" style="text-align: left;font-size: 0.8em;">{{item.lastUpdateDate |
                            formatDate}}
                        </div>
                    </nut-col>
                    <nut-col :span="8" style="line-height: 25px !important;">
                        <div class="flex-content" style="text-align: left;font-size: 0.8em;">主诊断</div>
                    </nut-col>
                    <nut-col :span="16" style="line-height: 25px !important;">
                        <div class="flex-content" style="text-align: left;font-size: 0.8em;">{{item.remark}}</div>
                    </nut-col>
                </nut-row>
            </div>
        </div>
    </div>
</template>

<script>
    /* eslint-disable no-undef,no-console */

    import navBar from '@/components/common/navBar.vue'

    export default {
        name: "record",
        components: {
            navBar
        },
        filters: {
            formatDate: function (time) {
                if (time != null && time != "") {
                    let date = new Date(time);
                    return formatDate(date, "yyyy-MM-dd hh:mm:ss");
                } else {
                    return "";
                }
            },
        },
        data() {
            return {
                list: []
            }
        },
        created() {

        },
        activated(){
            console.log("--------activated-------");
            this.getRecords();
            console.log("--------activated-------");
        },
        methods: {
            getRecords() {
                // 获取病人病历列表
                this.API.get("/rec/getPatientRecordList", {
                    params: {
                        pid: this.$store.state.patient.patientId,
                        startPage: 0,
                        size: 15
                    }
                }).then(({data}) => {
                    this.list = data.data.list || [];
                    console.log(this.list);
                })
            },
            chooseMyRecord(item) {
                console.log(item);
                this.$router.push({
                    name: 'recordDetail', params: {item: item, patient: this.$store.state.patient}
                });
            }
        }
    }
</script>

<style scoped>

    .recordList {
        background-color: #eee;
    }

    .recordList .list {
        margin-top: 50px;
    }

    .recordList .lsit_style {
        background-color: #fff;
        border-bottom: 1px solid #e6e6e6;
        min-height: 90px;
        padding-left: 20px;
        box-shadow: 1px 0px 1px 3px #eee;
        border-radius: 10px;
        margin: 0 3%;
    }

</style>